/*
* 1videoConference -- An open source video conferencing platform.
*
* Copyright (C) 2007 - 2008, Adiance Technologies Pvt. Ltd.
*
* Hardik Sanghvi <hardik.sanghvi @adiance.com>
*
* See http://www.1videoconference.org for more information about
* the 1videoConference project. Please do not directly contact
* any of the maintainers of this project for assistance;
* the project provides a web site, forums and mailing lists
* for your use.
*
* This program is free software, distributed under the terms of
* the GNU General Public License Version 2. See the LICENSE file
* at the top of the source tree.
*/

using System;
using System.Collections.Generic;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using Microsoft.Win32;
using System.Data;
using System.Data.SqlClient;
using System.IO;
using System.ServiceModel;
using System.Collections;

using _videoConference.BAL;
using NetPeerService;
using System.Net;

namespace _videoConference
{   
    public class MyMenu123
    {
        public int MenuId = 0;
        public int ParentId = 0;
        public string Caption = "";
        public BitmapImage btmImg = null;
        public string pagename = "";
    }

    public partial class DesignPage : System.Windows.Controls.Page,IDisposable
    {        
        AddPageControl ctrlpage = new AddPageControl();
        UploadModuleControl ctrluploadmodule = new UploadModuleControl();
        AddModuleControl ctrladdmodule;
        CreateMeeting cm;
        GenerateModule gm;
        IAddPage ia = new IAddPage();
        int count;
        int raxleft, raxtop;
        int mystate = 1;
        int mm = 1;
        MenuItem glo = new MenuItem();
        BitmapImage bmi = new BitmapImage();
        string filename = "";
        ContextMenu r123 = new ContextMenu();
        OpenFileDialog dlg = new OpenFileDialog();
        bool editmode = false;
        private bool disposed = false;

        public IsvcLoginStatusChannel svcLoginStatus;
        public NetPeerClient npcLoginStat;
        public object objLoginStat = new LoginClass();

        public IsvcLoginInfoChannel channelLoginInfo;
        public NetPeerClient clientLoginInfo;
        public object objectLoginInfo = new CsvcLoginInfo();

        public DesignPage()
        {
            InitializeComponent();

            UserInfo.MyCurrentPage = "DesignPage";
            this.ShowsNavigationUI = false;

            #region Services
            if (UserInfo.strMeetingMode == "Meeting Mode")
            {
                try
                {
                    npcLoginStat = new NetPeerClient();
                    svcLoginStatus = (IsvcLoginStatusChannel)npcLoginStat.OpenClient<IsvcLoginStatusChannel>("net.tcp://" + UserInfo.CreMachName + ":2500/LoginStatus", "LoginStatusMesh", ref objLoginStat);
                    ((LoginClass)objLoginStat).EntsvcJoin += new LoginClass.DelsvcJoin(DesignPage_EntsvcJoin);
                    ((LoginClass)objLoginStat).EntsvcDoLogin += new LoginClass.DelsvcDoLogin(DesignPage_EntsvcDoLogin);
                }
                catch (Exception exp)
                {
                    exp.Data.Add("My Key", "1videoConference--:--DesignPage.xaml.cs--:--DesignPage()--:--");
                    clsUtility.LogException = exp;
                    //MessageBox.Show("DesignPage(Login Status) : " + exp.Message);
                }

                try
                {
                    ((PageNavigationClass)PeerServices.objectPageNav).NewJoin += new PageNavigationClass.UserJoin(PNavClass_NewJoin);
                    ((PageNavigationClass)PeerServices.objectPageNav).SetPageName += new PageNavigationClass.PageName(PNavClass_SetPageName);
                    ((PageNavigationClass)PeerServices.objectPageNav).Logout += new PageNavigationClass.LogOutAll(PNavClass_Logout);
                    try
                    {
                        PeerServices.channelPageNav.svcJoin(UserInfo.UserName);
                    }
                    catch (Exception exp)
                    {
                        exp.Data.Add("My Key", "1videoConference--:--DesignPage.xaml.cs--:--DesignPage()1--:--");
                        clsUtility.LogException = exp;
                    }
                }
                catch (Exception exp)
                {
                    exp.Data.Add("My Key", "1videoConference--:--DesignPage.xaml.cs--:--DesignPage()0--:--");
                    clsUtility.LogException = exp;
                    //MessageBox.Show("Error on Events :" + exp.Message);
                }
            }
            #endregion

            #region variable declaration
            try
            {
                Uri adiUri = new Uri("http://www.adiance.com/");
                adiancehlink.NavigateUri = adiUri;
                btnDelete.IsEnabled = false;
                btnAdd.Click += new RoutedEventHandler(btnAdd_Click);
                btnAddModule.Click += new RoutedEventHandler(btnAddModule_Click);
                btnUpload.Click += new RoutedEventHandler(btnUpload_Click);
                inkForm.SizeChanged += new SizeChangedEventHandler(inkForm_SizeChanged);
                raxleft = 300;
                raxtop = 300;
                btnbrowse.Click += new RoutedEventHandler(btnbrowse_Click);
                btncancel.Click += new RoutedEventHandler(btncancel_Click);
                btndel.Click += new RoutedEventHandler(btndel_Click);
                btnok.Click += new RoutedEventHandler(btnok_Click);
                btnCreate.Click += new RoutedEventHandler(btnCreate_Click);
                btnManage.Click += new RoutedEventHandler(btnManage_Click);
                btnLogOut.Click += new RoutedEventHandler(btnLogOut_Click);
                btnZip.Click += new RoutedEventHandler(btnZip_Click);
                btnManageModule.Click += new RoutedEventHandler(btnManageModule_Click);
                glo.Foreground = Brushes.White;
                glo.VerticalAlignment = VerticalAlignment.Center;
                glo.MouseEnter += new MouseEventHandler(glo_MouseEnter);
                glo.MouseLeave += new MouseEventHandler(glo_MouseLeave);
                System.Windows.Application.Current.Exit += new ExitEventHandler(Current_Exit);
                
                Genmenu();
                
                if (mnu.Items.Count > 0)
                {
                    for (int i = 0; i < mnu.Items.Count; i++)
                    {
                        RemoveN((MenuItem)mnu.Items[i], true);
                    }
                }         
                   
                else if (UserInfo.strMeetingMode == "Meeting Mode" && UserInfo.MyRole == "Host")
                {
                    mnu.IsEnabled = true;
                }
               
                else if (UserInfo.strMeetingMode == "Design Mode")
                {
                    mnu.IsEnabled = true;
                }
                if (UserInfo.strMeetingMode == "Meeting Mode")
                {
                    cnvMain.Visibility = Visibility.Collapsed;
                    rdm2.Height = new GridLength(0.0, GridUnitType.Pixel);
                    inkForm.Height += 60.0;
                }
                else
                {
                    cnvMain.Visibility = Visibility.Visible;
                }               
                if (UserInfo.strMeetingMode == "Meeting Mode" && UserInfo.MyRole != "Host")
                {
                    mnu.IsEnabled = false;
                }
                this.Loaded += new RoutedEventHandler(DesignPage_Loaded);
                this.Unloaded += new RoutedEventHandler(DesignPage_Unloaded);
            }
            catch (Exception exp)
            {
                exp.Data.Add("My Key", "1videoConference--:--DesignPage.xaml.cs--:--DesignPage()2--:--");
                clsUtility.LogException = exp;
                //MessageBox.Show("1videoConference--:--DesignPage.xaml.cs--:--DesignPage()--:--" + exp.Message);
            }
            #endregion

        }

        void DesignPage_EntsvcUnSetMID(string mid)
        {
            
        }

        void LoginInfo_EntsvcJoin(string UName)
        {
            
        }
      
        void DesignPage_EntsvcDoLogin()
        {
            
        }

        void DesignPage_EntsvcJoin(string Role)
        {
            
        }

        void PNavClass_Logout(string meetingid)
        {
            try
            {
                if (UserInfo.MyRole != "Host" && UserInfo.MeetingID==meetingid)
                {
                    if (PeerServices.channelPageNav.State != CommunicationState.Closed)
                    {
                        PeerServices.clientPageNav.CloseClient<IPageNavigationChannel>();
                        //PeerServices.channelPageNav.Close();
                    }
                    if (PeerServices.channelPodResize.State != CommunicationState.Closed)
                    {
                        PeerServices.clientPodResize.CloseClient<IPodResizeChannel>();
                        //PeerServices.channelPodResize.Close();
                    }

                    if (PeerServices.objectPageNav != null)
                    {
                        PeerServices.objectPageNav = null;
                    }
                    if (PeerServices.objectPodResize != null)
                    {
                        PeerServices.objectPodResize = null;
                    }

                    //MessageBox.Show(this.NavigationService.ToString());
                    NavigationService.GetNavigationService(this).Navigate(new Uri("LogOn.xaml", UriKind.RelativeOrAbsolute));                   
                }
            }
            catch (Exception exp)
            {
                //MessageBox.Show("PageNav:" + exp.Message);
            }
        }

        void PNavClass_SetPageName(string layoutname,string meetingid)
        {
            try
            {
                if (UserInfo.MyRole != "Host" && layoutname!="" && UserInfo.MeetingID==meetingid)
                {
                    if (inkForm.Children.Count == 0)
                    {
                        gm.pagename = layoutname;
                        inkForm.Children.Add(gm);
                    }
                    else if (inkForm.Children.Count == 1 && ((GenerateModule)inkForm.Children[0]).pagename != layoutname)
                    {
                        ((GenerateModule)inkForm.Children[0]).pagename = layoutname;
                    }
                }
            }
            catch (Exception exp)
            {
                exp.Data.Add("My Key", "1videoConference--:--DesignPage.xaml.cs--:--PNavClass_SetPageName()--:--");
                clsUtility.LogException = exp;
                //clsUtility.LogException = exp;
                //MessageBox.Show("1videoConference--:--DesignPage.xaml.cs--:--PNavClass_SetPageName()--:--" + exp.Message);
            }    
        }

        void PNavClass_NewJoin(string uname)
        {                   
        }

        void DesignPage_Loaded(object sender, RoutedEventArgs e)
        {
            try
            {
                clientLoginInfo = new NetPeerClient();
                ((CsvcLoginInfo)objectLoginInfo).EntsvcJoin += new CsvcLoginInfo.DelsvcJoin(LoginInfo_EntsvcJoin);
                ((CsvcLoginInfo)objectLoginInfo).EntsvcUnSetMID += new CsvcLoginInfo.DelsvcUnSetMID(DesignPage_EntsvcUnSetMID);
                channelLoginInfo = (IsvcLoginInfoChannel)clientLoginInfo.OpenClient<IsvcLoginInfoChannel>("net.tcp://" + UserInfo.CreMachName + ":2500/LoginInfo", "LoginInfoMesh", ref objectLoginInfo);
                channelLoginInfo.svcJoin(UserInfo.UserName);
            }
            catch (Exception exp)
            {
                exp.Data.Add("My Key", "1videoConference--:--DesignPage.xaml.cs--:--DesignPage()--:--");
                clsUtility.LogException = exp;
                //MessageBox.Show("DesignPage(Login Info) : " + exp.Message);
            }
            try
            {
                gm = new GenerateModule();
                gm.newlayout();
            }
            catch (Exception exp)
            {
                //MessageBox.Show("GenerateModule in DesignPage: " + exp.Message);
            }

        }
      
        void glo_MouseLeave(object sender, MouseEventArgs e)
        {
            BacktoColor((System.Windows.Controls.MenuItem)sender);
        }

        void glo_MouseEnter(object sender, MouseEventArgs e)
        {
            ColorChange((System.Windows.Controls.MenuItem)sender);
        }

        void Current_Exit(object sender, ExitEventArgs e)
        {
            try
            {
                if (UserInfo.strMeetingMode == "Meeting Mode")
                {
                    try
                    {
                        if (inkForm.Children.Count > 0 && inkForm.Children[0].GetType().ToString() == "_videoConference.GenerateModule")
                        {
                            ((GenerateModule)inkForm.Children[0]).cnvMain.Children.Clear();
                        }
                    }
                    catch (Exception exp)
                    {
                        exp.Data.Add("My Key", "1videoConference--:--DesignPage.xaml.cs--:--Current_Exit()1--:--");
                        clsUtility.LogException = exp;
                        //clsUtility.LogException = exp;
                        //MessageBox.Show("1videoConference--:--DesignPage.xaml.cs--:--Current_Exit()--:--" + exp.Message);
                    }
                    inkForm.Children.Clear();

                    if (UserInfo.MyRole == "Host")
                    {
                        try
                        {
                            try
                            {
                                if (svcLoginStatus.State != CommunicationState.Closed)
                                {
                                    svcLoginStatus.svcJoin("LogOut");
                                }
                            }
                            catch (Exception exp)
                            {
                                //MessageBox.Show("Current_exit svcLoginStatus.svcJoin()" + exp.Message);
                            }
                            try
                            {
                                if (PeerServices.channelPageNav.State == CommunicationState.Opened)
                                {
                                    PeerServices.channelPageNav.svcLogOutAll(UserInfo.MeetingID);
                                }
                                if (svcLoginStatus.State != CommunicationState.Closed)
                                {
                                    svcLoginStatus.Close();
                                }
                                if (PeerServices.channelPageNav.State != CommunicationState.Closed)
                                {
                                    PeerServices.channelPageNav.Close();
                                }
                                if (PeerServices.channelPodResize.State != CommunicationState.Closed)
                                {
                                    PeerServices.channelPodResize.Close();
                                }
                                channelLoginInfo.svcUnSetMID(UserInfo.MeetingID);
                                

                                //UserInfo.objSvcLoginInfo.UnSetMID(UserInfo.MeetingID);
                            }
                            catch (Exception exp)
                            {
                                //MessageBox.Show("Current_Exit Services closed" + exp.Message);
                            }
                        }
                        catch (Exception exp)
                        {
                            exp.Data.Add("My Key", "1videoConference--:--DesignPage.xaml.cs--:--Current_Exit()2--:--");
                            clsUtility.LogException = exp;
                            //clsUtility.LogException = exp;
                            //MessageBox.Show("1videoConference--:--DesignPage.xaml.cs--:--Current_Exit()--:--" + exp.Message);
                        }
                    }
                    else
                    {
                        try
                        {
                            if (svcLoginStatus.State != CommunicationState.Closed)
                            {
                                svcLoginStatus.Close();
                            }
                            if (PeerServices.channelPageNav.State != CommunicationState.Closed)
                            {
                                PeerServices.channelPageNav.Close();
                            }
                            if (PeerServices.channelPodResize.State != CommunicationState.Closed)
                            {
                                PeerServices.channelPodResize.Close();
                            }
                        }
                        catch (Exception exp)
                        {
                            exp.Data.Add("My Key", "1videoConference--:--DesignPage.xaml.cs--:--Current_Exit()3--:--");
                            clsUtility.LogException = exp;
                            //MessageBox.Show("1videoConference--:--DesignPage.xaml.cs--:--Current_Exit()--:--" + exp.Message);
                        }
                    }
                }
            }
            catch (Exception exp)
            {
                exp.Data.Add("My Key", "1videoConference--:--DesignPage.xaml.cs--:--Current_Exit()4--:--");
                clsUtility.LogException = exp;
                //clsUtility.LogException = exp;
                //MessageBox.Show("1videoConference--:--DesignPage.xaml.cs--:--Current_Exit()--:--" + exp.Message);
            }
        }

        void DesignPage_Unloaded(object sender, RoutedEventArgs e)
        {
            if (UserInfo.strMeetingMode == "Meeting Mode")
            {
                #region ObjectDestruction-LoginStatus
                try
                {
                    if (objLoginStat != null)
                    { 
                        if (svcLoginStatus.State != CommunicationState.Closed)
                        {
                            svcLoginStatus.Close();
                            svcLoginStatus.Dispose();
                        }
                        objLoginStat = null;
                    }
                }
                catch (Exception exp)
                {
                    exp.Data.Add("My Key", "1videoConference--:--DesignPage.xaml.cs--:--DesignPage_Unloaded()--:--");
                    clsUtility.LogException = exp;
                    //MessageBox.Show("designpage unloaded: closing client for LoginStatus" + exp.Message);
                }
                #endregion

                #region ObjectDestruction-UriInfo
                try
                {
                    if (User.UserInfo.cui.objUriInfo != null)
                    {                        
                        User.UserInfo.cui.npcUriInfo.CloseClient<User.IsvcUriInfoChannel>();
                        User.UserInfo.cui.objUriInfo = null;
                    }
                }
                catch (Exception exp)
                {
                    exp.Data.Add("My Key", "1videoConference--:--DesignPage.xaml.cs--:--DesignPage_Unloaded()1--:--");
                    clsUtility.LogException = exp;
                    //MessageBox.Show("designpage unloaded: closing client for UriInfo" + exp.Message);
                }
                #endregion

                #region ObjectDestruction-LoginInfo
                try
                {
                    if (objectLoginInfo != null)
                    {
                       // clientLoginInfo.CloseClient<IsvcLoginInfoChannel>();
                        if (channelLoginInfo.State != CommunicationState.Closed)
                        {
                            channelLoginInfo.Close();
                            channelLoginInfo.Dispose();
                        }
                        objectLoginInfo = null;
                    }
                }
                catch (Exception exp)
                {
                    exp.Data.Add("My Key", "1videoConference--:--DesignPage.xaml.cs--:--DesignPage_Unloaded()2--:--");
                    clsUtility.LogException = exp;
                    //MessageBox.Show("designpage unloaded: closing client for LoginInfo" + exp.Message);
                }
                #endregion
            }
        }      

        void btnLogOut_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                if (UserInfo.strMeetingMode == "Meeting Mode")
                {
                    gm.pagename = "";
                    try
                    {
                        if (inkForm.Children.Count > 0 && inkForm.Children[0].GetType().ToString() == "_videoConference.GenerateModule")
                        {
                            ((GenerateModule)inkForm.Children[0]).cnvMain.Children.Clear();
                        }
                    }
                    catch (Exception exp)
                    {
                        exp.Data.Add("My Key", "1videoConference--:--DesignPage.xaml.cs--:--btnLogOut_Click()1--:--");
                        clsUtility.LogException = exp;
                        //MessageBox.Show("1videoConference--:--DesignPage.xaml.cs--:--btnLogOut_Click()--:--" + exp.Message);
                    }
                    inkForm.Children.Clear();

                    #region Host Logs Out

                    if (UserInfo.MyRole == "Host")
                    {
                        try
                        {
                            PeerServices.channelPageNav.svcLogOutAll(UserInfo.MeetingID);

                            svcLoginStatus.svcJoin("LogOut");

                            if (svcLoginStatus.State != CommunicationState.Closed)
                            {
                                svcLoginStatus.Close();
                            }
                            if (PeerServices.channelPageNav.State != CommunicationState.Closed)
                            {
                                PeerServices.clientPageNav.CloseClient<IPageNavigationChannel>();
                                //PeerServices.channelPageNav.Close();
                            }
                            if (PeerServices.channelPodResize.State != CommunicationState.Closed)
                            {
                                PeerServices.clientPodResize.CloseClient<IPodResizeChannel>();
                                //PeerServices.channelPodResize.Close();
                            }

                            if (PeerServices.objectPageNav != null)
                            {
                                PeerServices.objectPageNav = null;
                            }
                            if (PeerServices.objectPodResize != null)
                            {
                                PeerServices.objectPodResize = null;
                            }
                            channelLoginInfo.svcUnSetMID(UserInfo.MeetingID);
                            //UserInfo.objSvcLoginInfo.UnSetMID(UserInfo.MeetingID);
                        }
                        catch (Exception exp)
                        {
                            exp.Data.Add("My Key", "1videoConference--:--DesignPage.xaml.cs--:--btnLogOut_Click()2--:--");
                            clsUtility.LogException = exp;
                            //MessageBox.Show("1videoConference--:--DesignPage.xaml.cs--:--btnLogOut_Click()--:--" + exp.Message);
                        }
                    }
                    #endregion

                    #region Guest Logs Out
                    else
                    {
                        try
                        {
                            if (svcLoginStatus.State != CommunicationState.Closed)
                            {
                                svcLoginStatus.Close();
                            }
                            if (PeerServices.channelPageNav.State != CommunicationState.Closed)
                            {
                                PeerServices.channelPageNav.Close();                               
                            }
                            if (PeerServices.channelPodResize.State != CommunicationState.Closed)
                            {
                                PeerServices.channelPodResize.Close();
                            }
                            if (PeerServices.objectPageNav != null)
                            {
                                PeerServices.objectPageNav = null;
                            }
                            if (PeerServices.objectPodResize != null)
                            {
                                PeerServices.objectPodResize = null;
                            }
                        }
                        catch (Exception exp)
                        {
                            exp.Data.Add("My Key", "1videoConference--:--DesignPage.xaml.cs--:--btnLogOut_Click()3--:--");
                            clsUtility.LogException = exp;
                            //MessageBox.Show("1videoConference--:--DesignPage.xaml.cs--:--btnLogOut_Click()--:--" + exp.Message);
                        }
                    }
                    #endregion
                }               
                NavigationService.GetNavigationService(this).Navigate(new Uri("LogOn.xaml", UriKind.RelativeOrAbsolute));
            }
            catch (Exception exp)
            {
                exp.Data.Add("My Key", "1videoConference--:--DesignPage.xaml.cs--:--btnLogOut_Click()4--:--");
                clsUtility.LogException = exp;
                //MessageBox.Show("1videoConference--:--DesignPage.xaml.cs--:--btnLogOut_Click()--:--" + exp.Message);
            }
        }
        
        public void RemoveN(MenuItem curr, bool rot)
        {
            try
            {
                if (rot)
                {
                    if (curr.Header.ToString() == "*NEW ITEM*")
                    {
                        mnu.Items.Remove(curr);

                    }
                    else
                    {
                        if (curr.Items.Count > 0)
                        {
                            curr.MouseDoubleClick -= new MouseButtonEventHandler(mnuitem_MouseDoubleClick);
                            for (int i = 0; i < curr.Items.Count; i++)
                            {
                                RemoveN((MenuItem)curr.Items[i], false);
                            }
                        }
                    }
                }
                else
                {
                    if (curr.Header.ToString() == "*NEW ITEM*")
                    {
                        ((MenuItem)curr.Parent).Items.Remove(curr);

                    }
                    else
                    {
                        if (curr.Items.Count > 0)
                        {
                            curr.MouseDoubleClick -= new MouseButtonEventHandler(mnuitem_MouseDoubleClick);
                            for (int i = 0; i < curr.Items.Count; i++)
                            {
                                RemoveN((MenuItem)curr.Items[i], false);
                            }
                        }
                    }
                }
            }
            catch (Exception exp)
            {
                exp.Data.Add("My Key", "1videoConference--:--DesignPage.xaml.cs--:--RemoveN()--:--");
                clsUtility.LogException = exp;
                //clsUtility.LogException = exp;
                //MessageBox.Show("1videoConference--:--DesignPage.xaml.cs--:--RemoveN()--:--" + exp.Message);
            }
        }

        public void Genmenu()
        {
            try
            {
                DataSet ds = new DataSet();
                ds = ia.getmenu();

                DataSet dsmax = new DataSet();
                dsmax = ia.getmaxid();

                count = dsmax.Tables[0].Rows.Count;

                string temp;
                temp = dsmax.Tables[0].Rows[0][0].ToString();

                if (temp == "")
                {
                    count = 0;

                }
                else
                {
                    count = Int32.Parse(temp);
                }
                count++;


                DataSet ds1 = new DataSet();
                ds1 = ia.getorder();


                for (int i = 0; i < ds1.Tables[0].Rows.Count; i++)
                {
                    if (ds1.Tables[0].Rows[i][1].ToString() == "0")
                    {
                        MenuItem mnuItem = new MenuItem();
                        mnuItem.VerticalAlignment = VerticalAlignment.Center;
                        mnuItem.Foreground = Brushes.White;
                        mnuItem.MouseEnter+=new MouseEventHandler(mnuItem_MouseEnter);
                        mnuItem.MouseLeave+=new MouseEventHandler(mnuItem_MouseLeave);
                        MyMenu123 obj = new MyMenu123();
                        obj.MenuId = int.Parse(ds1.Tables[0].Rows[i][0].ToString());
                        obj.ParentId = 0;
                        obj.Caption = ds1.Tables[0].Rows[i][3].ToString();
                        if (ds1.Tables[0].Rows[i][4].ToString() != "")
                        {
                            obj.pagename = ds1.Tables[0].Rows[i][4].ToString();
                        }
                        else
                        {
                            obj.pagename = "";
                        }
                        mnuItem.Header = obj.Caption;
                        mnuItem.Tag = obj;
                        mnuItem.Click += new RoutedEventHandler(mnuitem_Click);
                        mnu.Items.Add(mnuItem);
                        BuildMenu(mnuItem);
                    }
                }

                for (int i = 0; i < mnu.Items.Count; i++)
                {
                    AddN((MenuItem)mnu.Items[i], true);
                }
                MenuItem mnuitem = new MenuItem();
                mnuitem.VerticalAlignment = VerticalAlignment.Center;
                mnuitem.Foreground = Brushes.White;
                mnuitem.MouseEnter+=new MouseEventHandler(mnuitem_MouseEnter);
                mnuitem.MouseLeave+=new MouseEventHandler(mnuitem_MouseLeave);
                mnuitem.Click += new RoutedEventHandler(mnuitem_Click);
                mnuitem.MouseDoubleClick += new MouseButtonEventHandler(mnuitem_MouseDoubleClick);
                mnuitem.Header = "*NEW ITEM*";

                mnu.Items.Add(mnuitem);

            }
            catch (Exception exp)
            {
                exp.Data.Add("My Key", "1videoConference--:--DesignPage.xaml.cs--:--Genmenu()--:--");
                clsUtility.LogException = exp;
                //clsUtility.LogException = exp;
                //MessageBox.Show("1videoConference--:--DesignPage.xaml.cs--:--Genmenu()--:--" + exp.Message);
            }
        }

        public void BuildMenu(MenuItem curr)
        {
            try
            {
                DataSet ds2 = new DataSet();
                ds2 = ia.getchildren(((MyMenu123)curr.Tag).MenuId);
                //DataRow[] myRows = dt.Select("ParentID = " + ((MyMenu123)curr.Tag).MenuId);

                for (int i = 0; i < ds2.Tables[0].Rows.Count; i++)
                {
                    MenuItem mnuItem = new MenuItem();
                    mnuItem.VerticalAlignment = VerticalAlignment.Center;
                    mnuItem.Foreground = Brushes.White;
                    mnuItem.MouseEnter += new MouseEventHandler(mnuItem_MouseEnter);
                    mnuItem.MouseLeave += new MouseEventHandler(mnuItem_MouseLeave);
                    MyMenu123 obj = new MyMenu123();
                    obj.MenuId = int.Parse(ds2.Tables[0].Rows[i][0].ToString());
                    obj.ParentId = int.Parse(ds2.Tables[0].Rows[i][1].ToString());
                    obj.Caption = ds2.Tables[0].Rows[i][3].ToString();
                    if (ds2.Tables[0].Rows[i][4].ToString() != "")
                    {
                        obj.pagename = ds2.Tables[0].Rows[i][4].ToString();
                    }

                    if (ds2.Tables[0].Rows[i][2] != DBNull.Value)
                    {
                        byte[] rax = (byte[])ds2.Tables[0].Rows[i][2];
                        System.Windows.Controls.Image img2 = new System.Windows.Controls.Image();
                        BitmapImage bImg1 = new BitmapImage();

                        bImg1.BeginInit();
                        bImg1.StreamSource = new MemoryStream(rax);
                        bImg1.EndInit();

                        obj.btmImg = bImg1;
                        img2.Source = bImg1;
                        mnuItem.Icon = img2;
                    }

                    mnuItem.Header = obj.Caption;
                    mnuItem.Click += new RoutedEventHandler(mnuitem_Click);
                    mnuItem.Tag = obj;
                    curr.Items.Add(mnuItem);
                    BuildMenu(mnuItem);
                }
            }
            catch (Exception exp)
            {
                exp.Data.Add("My Key", "1videoConference--:--DesignPage.xaml.cs--:--BuildMenu()--:--");
                clsUtility.LogException = exp;
                //clsUtility.LogException = exp;
                //MessageBox.Show("1videoConference--:--DesignPage.xaml.cs--:--BuildMenu()--:--" + exp.Message);
            }
        }

        void mnuItem_MouseLeave(object sender, MouseEventArgs e)
        {
            BacktoColor((System.Windows.Controls.MenuItem)sender);
        }

        void mnuItem_MouseEnter(object sender, MouseEventArgs e)
        {
            ColorChange((System.Windows.Controls.MenuItem)sender);
        }

        public void AddN(MenuItem curr, bool rot)
        {
            try
            {
                if (rot)
                {
                    curr.MouseDoubleClick += new MouseButtonEventHandler(mnuitem_MouseDoubleClick);
                    if (curr.Items.Count > 0)
                    {

                        for (int i = 0; i < curr.Items.Count; i++)
                        {
                            AddN((MenuItem)curr.Items[i], true);
                        }
                    }
                    MenuItem mnuitem = new MenuItem();
                    mnuitem.VerticalAlignment = VerticalAlignment.Center;
                    mnuitem.Foreground = Brushes.White;
                    mnuitem.MouseEnter += new MouseEventHandler(mnuitem_MouseEnter);
                    mnuitem.MouseLeave += new MouseEventHandler(mnuitem_MouseLeave);
                    mnuitem.Click += new RoutedEventHandler(mnuitem_Click);
                    mnuitem.MouseDoubleClick += new MouseButtonEventHandler(mnuitem_MouseDoubleClick);
                    mnuitem.Header = "*NEW ITEM*";
                    curr.Items.Add(mnuitem);
                }
                else
                {
                    curr.MouseDoubleClick += new MouseButtonEventHandler(mnuitem_MouseDoubleClick);
                }
            }
            catch (Exception exp)
            {
                exp.Data.Add("My Key", "1videoConference--:--DesignPage.xaml.cs--:--AddN()--:--");
                clsUtility.LogException = exp;
                //clsUtility.LogException = exp;
                //MessageBox.Show("1videoConference--:--DesignPage.xaml.cs--:--AddN()--:--" + exp.Message);
            }
        }

        void mnuitem_MouseLeave(object sender, MouseEventArgs e)
        {
            BacktoColor((System.Windows.Controls.MenuItem)sender);
        }

        void mnuitem_MouseEnter(object sender, MouseEventArgs e)
        {
            ColorChange((System.Windows.Controls.MenuItem)sender);
        }

        void btndel_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                mystate = 1;
                glo.Items.Clear();

                MenuItem parent1 = new MenuItem();
                parent1.VerticalAlignment = VerticalAlignment.Center;
                parent1.Foreground = Brushes.White;
                parent1.MouseEnter += new MouseEventHandler(parent1_MouseEnter);
                parent1.MouseLeave += new MouseEventHandler(parent1_MouseLeave);
                if (glo.Parent.GetType().ToString() == "System.Windows.Controls.Menu")
                {
                    mnu.Items.Remove(glo);                    
                    //MessageBox.Show(((MyMenu123)glo.Tag).pagename);
                }
                else
                {
                    parent1 = (MenuItem)glo.Parent;
                    parent1.Items.Remove(glo);
                    //MessageBox.Show(((MyMenu123)glo.Tag).pagename);
                }
                visible1();
                ctrlpage.fillcombo();
            }
            catch (Exception exp)
            {
                exp.Data.Add("My Key", "1videoConference--:--DesignPage.xaml.cs--:--btndel_Click()--:--");
                clsUtility.LogException = exp;
                //clsUtility.LogException = exp;
                //MessageBox.Show("1videoConference--:--DesignPage.xaml.cs--:--btndel_Click()--:--" + exp.Message);
            }
        }

        void parent1_MouseLeave(object sender, MouseEventArgs e)
        {
            BacktoColor((System.Windows.Controls.MenuItem)sender);
        }

        void parent1_MouseEnter(object sender, MouseEventArgs e)
        {
            ColorChange((System.Windows.Controls.MenuItem)sender);
        }

        void btnbrowse_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                dlg.FileName = "";
                dlg.DefaultExt = ".ico";
                dlg.Filter = "Icon Files (.ico)|*.ico";
                Nullable<bool> result = dlg.ShowDialog();
                if (result == true)
                {
                    filename = dlg.FileName;
                    BitmapImage bmi = new BitmapImage();
                    bmi.BeginInit();
                    bmi.StreamSource = new FileStream(filename, FileMode.Open, FileAccess.Read);
                    bmi.EndInit();
                    img.Source = bmi;
                    img.Visibility = Visibility.Visible;
                }
            }
            catch (Exception exp)
            {
                exp.Data.Add("My Key", "1videoConference--:--DesignPage.xaml.cs--:--btnbrowse_Click()--:--");
                clsUtility.LogException = exp;
                //MessageBox.Show("1videoConference--:--DesignPage.xaml.cs--:--btnbrowse_Click()--:--" + exp.Message);
            }
        }

        void btnok_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                visible1();
                mystate = 1;
                if (glo.Header.ToString() == "*NEW ITEM*")
                {

                    string chkstr;
                    chkstr = txtTemp.Text.ToString();

                    if (chkstr.ToString() == "")
                        goto rax;
                    else
                        glo.Header = chkstr;

                    if (filename != "" && glo.Parent.GetType().ToString() != "System.Windows.Controls.Menu")
                    {
                        BitmapImage bImg = new BitmapImage();
                        bImg.BeginInit();
                        bImg.StreamSource = new FileStream(filename, FileMode.Open, FileAccess.Read);
                        bImg.EndInit();
                        System.Windows.Controls.Image img2 = new System.Windows.Controls.Image();
                        img2.Source = bImg;
                        glo.Icon = img2;
                    }


                    if (txtparid.Text == "")
                        txtparid.Text = "0";
                    BitmapImage bImg1 = new BitmapImage();
                    if (txtparid.Text != "0" && filename != "")
                    {

                        bImg1.BeginInit();
                        bImg1.StreamSource = new FileStream(filename, FileMode.Open, FileAccess.Read);
                        bImg1.EndInit();
                        bImg1.StreamSource.Position = 0;
                        byte[] myBytes = new byte[int.Parse(bImg1.StreamSource.Length.ToString())];
                        bImg1.StreamSource.Read(myBytes, 0, myBytes.Length);

                    }

                    MyMenu123 obj = new MyMenu123();
                    obj.Caption = txtTemp.Text;
                    obj.MenuId = Int32.Parse(txtid.Text);
                    obj.ParentId = Int32.Parse(txtparid.Text);
                    obj.pagename = txtpagename.Text;
                    if (txtparid.Text == "0" || filename == "")
                    {
                    }
                    else
                    {
                        obj.btmImg = bImg1;
                    }

                    glo.Tag = obj;

                    MenuItem mnuitem = new MenuItem();
                    mnuitem.VerticalAlignment = VerticalAlignment.Center;
                    mnuitem.Foreground = Brushes.White;
                    mnuitem.MouseEnter+=new MouseEventHandler(mnuitem_MouseEnter);
                    mnuitem.MouseLeave+=new MouseEventHandler(mnuitem_MouseLeave);
                    mnuitem.Header = "*NEW ITEM*";
                    glo.Items.Add(mnuitem);
                    mnuitem.Click += new RoutedEventHandler(mnuitem_Click);
                    mnuitem.MouseDoubleClick += new MouseButtonEventHandler(mnuitem_MouseDoubleClick);

                    MenuItem mnuitem1 = new MenuItem();
                    mnuitem1.VerticalAlignment = VerticalAlignment.Center;
                    mnuitem1.Foreground = Brushes.White;
                    mnuitem1.MouseLeave += new MouseEventHandler(mnuitem1_MouseLeave);
                    mnuitem1.MouseEnter += new MouseEventHandler(mnuitem1_MouseEnter);
                    mnuitem1.Header = "*NEW ITEM*";

                    if (((MenuItem)glo).Parent.GetType().ToString() == "System.Windows.Controls.Menu")
                    {
                        mnu.Items.Add(mnuitem1);
                    }
                    else
                    {
                        MenuItem parent1 = (MenuItem)glo.Parent;
                        parent1.Items.Add(mnuitem1);
                    }
                    mnuitem1.Click += new RoutedEventHandler(mnuitem_Click);
                    mnuitem1.MouseDoubleClick += new MouseButtonEventHandler(mnuitem_MouseDoubleClick);
                rax: ;
                }
                else
                {
                    BitmapImage bImg1 = new BitmapImage();
                    if (txtparid.Text != "0" && filename != "")
                    {
                        bImg1.BeginInit();
                        bImg1.StreamSource = new FileStream(filename, FileMode.Open, FileAccess.Read);
                        bImg1.EndInit();
                        bImg1.StreamSource.Position = 0;
                        byte[] myBytes = new byte[int.Parse(bImg1.StreamSource.Length.ToString())];
                        bImg1.StreamSource.Read(myBytes, 0, myBytes.Length);

                    }

                    MyMenu123 obj = new MyMenu123();
                    obj.Caption = txtTemp.Text;
                    obj.MenuId = Int32.Parse(txtid.Text);
                    obj.ParentId = Int32.Parse(txtparid.Text);
                    obj.pagename = txtpagename.Text;
                    if (txtparid.Text == "0")
                    {
                    }
                    else
                    {
                        obj.btmImg = bImg1;
                    }

                    glo.Tag = obj;
                    count--;
                    string chkstr;
                    chkstr = txtTemp.Text.ToString();

                    if (chkstr.ToString() == "")
                        goto rax;
                    else
                        glo.Header = chkstr;



                    if (filename != "" && glo.Parent.GetType().ToString() != "System.Windows.Controls.Menu")
                    {
                        BitmapImage bImg = new BitmapImage();
                        bImg.BeginInit();
                        bImg.UriSource = new Uri(filename);
                        bImg.EndInit();
                        System.Windows.Controls.Image img2 = new System.Windows.Controls.Image();
                        img2.Source = bImg;
                        glo.Icon = img2;
                    }
                rax: ;
                }
                count++;
                filename = "";
                editmode = false;

                ctrlpage.fillcombo();
            }
            catch (Exception exp)
            {
                exp.Data.Add("My Key", "1videoConference--:--DesignPage.xaml.cs--:--btnok_click()--:--");
                clsUtility.LogException = exp;
                //MessageBox.Show("1videoConference--:--DesignPage.xaml.cs--:--btnok_Click()--:--" + exp.Message);
            }
        }

        void mnuitem1_MouseEnter(object sender, MouseEventArgs e)
        {
            ColorChange((System.Windows.Controls.MenuItem)sender);
        }

        void mnuitem1_MouseLeave(object sender, MouseEventArgs e)
        {
            BacktoColor((System.Windows.Controls.MenuItem)sender);
        }
               
        void btncancel_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                visible1();
                editmode = false;
                mystate = 1;
            }
            catch (Exception exp)
            {
                exp.Data.Add("My Key", "1videoConference--:--DesignPage.xaml.cs--:--btncancel_click()--:--");
                clsUtility.LogException = exp;
                //clsUtility.LogException = exp;
                //MessageBox.Show("1videoConference--:--DesignPage.xaml.cs--:--btncancel_Click()--:--" + exp.Message);
            }
        }

        void txtTemp_KeyDown(object sender, KeyEventArgs e)
        {
            try
            {
                if (e.Key == Key.Enter)
                {
                    visible1();
                }
            }
            catch (Exception exp)
            {
                exp.Data.Add("My Key", "1videoConference--:--DesignPage.xaml.cs--:--txtTemp_KeyDown()--:--");
                clsUtility.LogException = exp;
                //clsUtility.LogException = exp;
                //MessageBox.Show("1videoConference--:--DesignPage.xaml.cs--:--txtTemp_KeyDown()--:--" + exp.Message);
            }
        }

        void visible1()
        {
            try
            {
                cnvHeader.Visibility = Visibility.Visible;
                cnvFooter.Visibility = Visibility.Visible;
                cnvMain.Visibility = Visibility.Visible;
                inkForm.Visibility = Visibility.Visible;
                mnu.IsEnabled = true;

                txtTemp.Visibility = Visibility.Collapsed;
                lblheading.Visibility = Visibility.Collapsed;
                lblheading1.Visibility = Visibility.Collapsed;
                rectshape.Visibility = Visibility.Collapsed;
                rectshape1.Visibility = Visibility.Collapsed;

                lblico.Visibility = Visibility.Collapsed;
                img.Visibility = Visibility.Collapsed;
                btnok.Visibility = Visibility.Collapsed;
                btncancel.Visibility = Visibility.Collapsed;
                btndel.Visibility = Visibility.Collapsed;
                btnbrowse.Visibility = Visibility.Collapsed;
                txtid.Visibility = Visibility.Collapsed;
                txtparid.Visibility = Visibility.Collapsed;
                txtpagename.Visibility = Visibility.Collapsed;

                mnu.IsEnabled = true;
            }
            catch (Exception exp)
            {
                exp.Data.Add("My Key", "1videoConference--:--DesignPage.xaml.cs--:--visible()1--:--");
                clsUtility.LogException = exp;
                //clsUtility.LogException = exp;
                //MessageBox.Show("1videoConference--:--DesignPage.xaml.cs--:--visible1()--:--" + exp.Message);
            }

        }

        void invisible1()
        {
            try
            {
                cnvHeader.Visibility = Visibility.Collapsed;
                cnvFooter.Visibility = Visibility.Collapsed;
                cnvMain.Visibility = Visibility.Collapsed;
                inkForm.Visibility = Visibility.Collapsed;

                txtTemp.Visibility = Visibility.Visible;
                lblheading.Visibility = Visibility.Visible;
                lblheading1.Visibility = Visibility.Visible;
                rectshape.Visibility = Visibility.Visible;
                rectshape1.Visibility = Visibility.Visible;


                if (txtparid.Text != "")
                {
                    btnbrowse.Visibility = Visibility.Visible;
                    lblico.Visibility = Visibility.Visible;
                }
                btnok.Visibility = Visibility.Visible;
                btncancel.Visibility = Visibility.Visible;
            }
            catch (Exception exp)
            {
                exp.Data.Add("My Key", "1videoConference--:--DesignPage.xaml.cs--:--visible()2--:--");
                clsUtility.LogException = exp;
                //clsUtility.LogException = exp;
               // MessageBox.Show("1videoConference--:--DesignPage.xaml.cs--:--invisible1()--:--" + exp.Message);
            }
        }

        void mnuitem_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                if (mystate == 1)
                {
                    glo = ((MenuItem)sender);

                    if (glo.Header.ToString() == "*NEW ITEM*")
                    {
                        invisible1();
                        txtTemp.Text = "New Menu Item";
                        txtpagename.Text = "";
                        img.Visibility = Visibility.Collapsed;
                        if (glo.Parent.GetType().ToString() != "System.Windows.Controls.Menu")
                        {
                            MenuItem a = (MenuItem)glo.Parent;
                            txtparid.Text = ((MyMenu123)a.Tag).MenuId.ToString();
                            lblico.Visibility = Visibility.Visible;
                            btnbrowse.Visibility = Visibility.Visible;
                        }
                        else
                        {
                            txtparid.Text = "";
                            btnbrowse.Visibility = Visibility.Collapsed;
                            lblico.Visibility = Visibility.Collapsed;
                            img.Visibility = Visibility.Collapsed;
                        }
                        txtid.Text = (count).ToString();
                    }
                    else
                    {
                    }
                    mystate = 0;
                }

                if (mm == 1)
                {
                    int myflag123 = 0;
                    for (int i = 0; i < mnu.Items.Count; i++)
                    {
                        if (((MenuItem)mnu.Items[i]).Header.ToString() == "*NEW ITEM*")
                        {
                            myflag123 = 1;
                        }
                    }
                    if (myflag123 == 0)
                    {
                        if (inkForm.Children.Count == 0)
                        {
                            gm.pagename = ((MyMenu123)((MenuItem)sender).Tag).pagename.ToString();
                            if (UserInfo.strMeetingMode == "Design Mode")
                            {
                                mnu.IsEnabled = false;
                            }

                            inkForm.Children.Add(gm);
                            mm = 0;
                            if (((MyMenu123)((MenuItem)sender).Tag).pagename != "" && UserInfo.strMeetingMode == "Meeting Mode")
                            {
                                try
                                {
                                    PeerServices.channelPageNav.svcSetPageName(((MyMenu123)((MenuItem)sender).Tag).pagename,UserInfo.MeetingID);
                                    //channelPageNav.svcSetPageName(((MyMenu123)((MenuItem)sender).Tag).pagename);
                                    //proxy.svcGetMessage(((MyMenu123)((MenuItem)sender).Tag).pagename);                                    
                                }
                                catch (Exception exp)
                                {
                                    exp.Data.Add("My Key", "1videoConference--:--DesignPage.xaml.cs--:--mnuitem_click()--:--");
                                    clsUtility.LogException = exp;
                                    //clsUtility.LogException = exp;
                                    //MessageBox.Show("1videoConference--:--DesignPage.xaml.cs--:--mnuitem_Click()--:--" + exp.Message);
                                }
                            }
                        }
                        else if (inkForm.Children.Count == 1)
                        {
                            ((GenerateModule)inkForm.Children[0]).pagename = ((MyMenu123)((MenuItem)sender).Tag).pagename.ToString();
                            if (UserInfo.strMeetingMode == "Design Mode")
                            {
                                mnu.IsEnabled = false;
                            }
                            mm = 0;
                            if (((MyMenu123)((MenuItem)sender).Tag).pagename != "" && UserInfo.strMeetingMode == "Meeting Mode")
                            {
                                try
                                {
                                    PeerServices.channelPageNav.svcSetPageName(((MyMenu123)((MenuItem)sender).Tag).pagename,UserInfo.MeetingID);
                                    //channelPageNav.svcSetPageName(((MyMenu123)((MenuItem)sender).Tag).pagename);
                                    //proxy.svcGetMessage(((MyMenu123)((MenuItem)sender).Tag).pagename);                                    
                                }
                                catch (Exception exp)
                                {
                                    exp.Data.Add("My Key", "1videoConference--:--DesignPage.xaml.cs--:--mnuitem_click()2--:--");
                                    clsUtility.LogException = exp;
                                    //clsUtility.LogException = exp;
                                    //MessageBox.Show("1videoConference--:--DesignPage.xaml.cs--:--mnuitem_Click()--:--" + exp.Message);
                                }
                            }
                        }
                    }
                }
                if (((MenuItem)sender).Parent.GetType().ToString() == "System.Windows.Controls.Menu")
                {
                    mm = 1;
                }
            }
            catch (Exception exp)
            {
                //clsUtility.LogException = exp;
                //MessageBox.Show("1videoConference--:--DesignPage.xaml.cs--:--mnuitem_Click()--:--" + exp.Message);
                exp.Data.Add("My Key", "1videoConference--:--DesignPage.xaml.cs--:--mnuitem_click()3--:--");
                clsUtility.LogException = exp;
            }
        }              

        void mnuitem_MouseDoubleClick(object sender, MouseButtonEventArgs e)
        {
            try
            {
                BitmapImage bmi123 = new BitmapImage();
                if (mystate == 1)
                {
                    MenuItem mymen = new MenuItem();
                    mymen.VerticalAlignment = VerticalAlignment.Center;
                    mymen.Foreground = Brushes.White;
                    mymen.MouseEnter += new MouseEventHandler(mymen_MouseEnter);
                    mymen.MouseLeave += new MouseEventHandler(mymen_MouseLeave);
                    mymen = (MenuItem)sender;
                    if (mymen.Header.ToString() != "*NEW ITEM*")
                    {
                        editmode = true;
                        glo = ((MenuItem)sender);
                        invisible1();
                        txtTemp.Text = glo.Header.ToString();
                        txtid.Text = ((MyMenu123)glo.Tag).MenuId.ToString();
                        txtpagename.Text = ((MyMenu123)glo.Tag).pagename.ToString();
                        img.Source = (BitmapImage)((MyMenu123)glo.Tag).btmImg;
                        img.Visibility = Visibility.Visible;
                        btndel.Visibility = Visibility.Visible;
                        txtparid.Text = ((MyMenu123)glo.Tag).ParentId.ToString();


                        if (glo.Parent.GetType().ToString() == "System.Windows.Controls.Menu")
                        {
                            txtparid.Text = "0";
                            btnbrowse.Visibility = Visibility.Collapsed;
                            lblico.Visibility = Visibility.Collapsed;
                        }

                        if (((MenuItem)glo).Parent.GetType().ToString() != "System.Windows.Controls.Menu")
                        {

                        }
                    }
                    mystate = 0;
                }

                if (((MenuItem)sender).Parent.GetType().ToString() == "System.Windows.Controls.Menu")
                {
                    mystate = 1;
                }
            }
            catch (Exception exp)
            {
                //clsUtility.LogException = exp;
               // MessageBox.Show("1videoConference--:--DesignPage.xaml.cs--:--mnuitem_MouseDoubleClick()--:--" + exp.Message);
                exp.Data.Add("My Key", "1videoConference--:--DesignPage.xaml.cs--:--mnuitem_MouseDoubleClick()--:--");
                clsUtility.LogException = exp;
            }
        }

        void mymen_MouseLeave(object sender, MouseEventArgs e)
        {
            BacktoColor((System.Windows.Controls.MenuItem)sender);
        }

        void mymen_MouseEnter(object sender, MouseEventArgs e)
        {
            ColorChange((System.Windows.Controls.MenuItem)sender);
        }
                
        void inkForm_SizeChanged(object sender, SizeChangedEventArgs e)
        {
            try
            {
                if (e.NewSize.Height.ToString() == "250")
                {
                    GridLength gl = new GridLength(400.0 + 60.0, GridUnitType.Pixel);
                    rd1.Height = gl;
                }
                else
                {
                    GridLength gl = new GridLength(e.NewSize.Height + 60.0, GridUnitType.Pixel);
                    rd1.Height = gl;
                }

                if (e.NewSize.Width < 1024.0)
                {
                    GridLength gl = new GridLength(1024.0, GridUnitType.Pixel);
                    cd1.Width = gl;
                }
                else
                {
                    GridLength gl = new GridLength(e.NewSize.Width, GridUnitType.Pixel);
                    cd1.Width = gl;
                }
            }
            catch (Exception exp)
            {
                exp.Data.Add("My Key", "1videoConference--:--DesignPage.xaml.cs--:--inkForm_SizeChanged()--:--");
                clsUtility.LogException = exp;
                //clsUtility.LogException = exp;
                //MessageBox.Show("1videoConference--:--DesignPage.xaml.cs--:--inkForm_SizeChanged()--:--" + exp.Message);
            }
        }

        void btnUpload_Click(object sender, RoutedEventArgs e)
        {
            try
            {               
                cnvMain.IsEnabled = false;
                mnu.IsEnabled = false;
                inkForm.Children.Add(ctrluploadmodule);
            }
            catch (Exception exp)
            {
                exp.Data.Add("My Key", "1videoConference--:--DesignPage.xaml.cs--:--btnUpload_Click()--:--");
                clsUtility.LogException = exp;
                //clsUtility.LogException = exp;
                //MessageBox.Show("1videoConference--:--DesignPage.xaml.cs--:--btnUpload_Click()--:--" + exp.Message);
            }
        }

        void btnAddModule_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                ctrladdmodule = new AddModuleControl();
                cnvMain.IsEnabled = false;
                mnu.IsEnabled = false;
                inkForm.Children.Add(ctrladdmodule);
            }
            catch (Exception exp)
            {
                exp.Data.Add("My Key", "1videoConference--:--DesignPage.xaml.cs--:--btnAddModule_Click()--:--");
                clsUtility.LogException = exp;
                //clsUtility.LogException = exp;
                //MessageBox.Show("1videoConference--:--DesignPage.xaml.cs--:--btnAddModule_Click()--:--" + exp.Message);
            }
        }

        void btnAdd_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                cnvMain.IsEnabled = false;
                mnu.IsEnabled = true;
                inkForm.Children.Add(ctrlpage);
                mnu.Items.Clear();
                Genmenu();
                ctrlpage.fillcombo();
                mystate = 1;
            }
            catch (Exception exp)
            {
                exp.Data.Add("My Key", "1videoConference--:--DesignPage.xaml.cs--:--btnAdd_Click()--:--");
                clsUtility.LogException = exp;
                //clsUtility.LogException = exp;
                //MessageBox.Show("1videoConference--:--DesignPage.xaml.cs--:--btnAdd_Click()--:--" + exp.Message);
            }
        }

        void btnManage_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                ManageMeeting mm = new ManageMeeting();
                inkForm.Children.Clear();
                inkForm.Children.Add(mm);
                mnu.IsEnabled = false;
                cnvMain.IsEnabled = false;
            }
            catch (Exception exp)
            {
                //clsUtility.LogException = exp;
                //MessageBox.Show("1videoConference--:--DesignPage.xaml.cs--:--btnManage_Click()--:--" + exp.Message);
                exp.Data.Add("My Key", "1videoConference--:--DesignPage.xaml.cs--:--btnManage_Click()--:--");
                clsUtility.LogException = exp;
            }
        }

        void btnCreate_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                cm = new CreateMeeting();
                inkForm.Children.Add(cm);
                mnu.IsEnabled = false;
                cnvMain.IsEnabled = false;
            }
            catch (Exception exp)
            {
                //clsUtility.LogException = exp;
                //MessageBox.Show("1videoConference--:--DesignPage.xaml.cs--:--btnCreate_Click()--:--" + exp.Message);
                exp.Data.Add("My Key", "1videoConference--:--DesignPage.xaml.cs--:--btnCreate_Click()--:--");
                clsUtility.LogException = exp;
            }
        }

        void btnManageModule_Click(object sender, RoutedEventArgs e)
        {
            ManageModule mgmt = new ManageModule();
            inkForm.Children.Clear();
            inkForm.Children.Add(mgmt);
            mnu.IsEnabled = false;
            cnvMain.IsEnabled = false;
        }

        void btnZip_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                ZipManagement zm = new ZipManagement();
                inkForm.Children.Clear();
                inkForm.Children.Add(zm);
                mnu.IsEnabled = false;
                cnvMain.IsEnabled = false;
            }
            catch (Exception exp)
            {
                exp.Data.Add("My Key", "1videoConference--:--DesignPage.xaml.cs--:--btnZip_Click()--:--");
                clsUtility.LogException = exp;
            }
        }
        
        public void logolink(object o, MouseButtonEventArgs e)
        {
            try
            {
                vclink.NavigateUri = new Uri("http://www.1videoconference.com");
                vclink.TargetName = "window1";
                vclink.DoClick();
            }
            catch (Exception exp)
            {
                //clsUtility.LogException = exp;
                //MessageBox.Show("1videoConference--:--DesignPage.xaml.cs--:--logolink()--:--" + exp.Message);
                exp.Data.Add("My Key", "1videoConference--:--DesignPage.xaml.cs--:--logolink()--:--");
                clsUtility.LogException = exp;
            }
        }

        public void ColorChange(System.Windows.Controls.MenuItem mnI)
        {
            mnI.Background = Brushes.LightGray;
            mnI.Foreground = Brushes.Black;
        }

        public void BacktoColor(System.Windows.Controls.MenuItem mnI)
        {
            LinearGradientBrush l;
            GradientStop gs1;
            GradientStop gs2;


            this.Tag = this.Parent;

            l = new LinearGradientBrush();

            Point p1 = new Point(0.0, 0.5);
            Point p2 = new Point(1.0, 0.5);

            l.StartPoint = p1;
            l.EndPoint = p2;

            gs2 = new GradientStop(System.Windows.Media.Color.FromRgb(89, 89, 89), 0.11428571428571427);
            gs1 = new GradientStop(System.Windows.Media.Color.FromRgb(115, 115, 115), 0.51428571428571427);

            System.Windows.Media.RotateTransform RT;
            RT = new RotateTransform(90.0);

            l.Transform = RT;
            l.GradientStops.Add(gs1);
            l.GradientStops.Add(gs2);


            mnI.Background = l;
            mnI.Foreground = Brushes.White;

        }

        public void Dispose()
        {
            Dispose(true);
            GC.SuppressFinalize(this);    
        }

         private void Dispose(bool disposing)
        {
            if(!this.disposed)
            {
                if(disposing)
                { 
                   
                }        
                disposed = true;

            }
        }

        ~DesignPage()
        {
            Dispose(false);
        }
   }
}